package br.com.gscorp.bankLion.json;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * @author marcelofelix
 * 
 */
public class LocalDateJsonSerializer extends JsonSerializer<LocalDate> {

	/**
	 * (non-Javadoc) {@inheritDoc}
	 * 
	 * @see org.codehaus.jackson.map.JsonSerializer#serialize(java.lang.Object,
	 *      org.codehaus.jackson.JsonGenerator,
	 *      org.codehaus.jackson.map.SerializerProvider)
	 */
	@Override
	public void serialize(final LocalDate value, final JsonGenerator jgen, final SerializerProvider provider)
			throws IOException {
		DateTimeFormatter format = DateTimeFormat.forPattern("dd/MM/yyyy");
		jgen.writeString(format.print(value));

	}
}